/**
  ETFDAQ Project
  \class TAmADC32
  \brief a 32 ECL ch ADC Mesytec card
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2024-09-05
  \date 2024-09-05 last modified

  \copyright Copyright (c) 2024 IMP-CAS with LGPLv3 LICENSE
*/

#ifndef TAmADC32_h
#define TAmADC32_h

#include "TAMesytec.h"

class TAmADC32 : public TAMesytec{
public:
  TAmADC32(TAController *ctrl, const TAYaml &c);
  virtual ~TAmADC32();

  virtual void Initialize() override; ///< config the card

  virtual void SetThreshold(int ch, uint16_t thre) const override;
  /// overflow and zero suppressions
  virtual void KeepUnderflow(bool opt = true) const override;
  virtual void KeepOverflow(bool opt = true) const override;
  virtual void Print() const override; ///< print config info
  virtual void PrintEvent(const uint32_t *ev)  override; ///< print one event

  /// [0-1-2-3-4]: [2,4,4h,8,8h]k
  virtual void SetResolution(uint16_t res) override;
  virtual void SetInputRange(uint16_t r); ///< 0-1-2: 4-10-8V

  static const double kInputRange[3]; ///< input range
  static const int kResN[5]; ///< ch width
  /// conversion time in us
  static const double kResConvT[5];

protected:
  uint16_t fResN; ///< in V
  double fInputRange, fResConvT; ///< conversion time in us

  bool fUseGate;
  uint16_t fGateDelay[2], fGateWidth[2]; ///< bank0-1, in ns
};

#endif
